home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d1
/
esc.arc
/
ESC.DOC
< prev
next >
Wrap
Text File
|
1986-08-27
|
21KB
|
498 lines
_______ PROGRAM: ESC.COM _______________________________________________
PURPOSE: utility to configure DOS ANSI console.
USAGE: ESC xxxxxx
WHERE: xxxxxx is an ANSI escape sequence.
Escape sequences are control codes that change cursor, screen, keyboard,
or speaker attributes. Control codes are useful for customizing your PC
without having to deal directly with console hardware.
ANSI consoles are devices that respond to "ANSI X3.64" escape sequences.
American Standard terminals are ANSI console devices. The IBM PC is not
an ANSI device and does not respond to escape codes until you install an
ANSI "console device driver."
DOS provides a driver called "ANSI.SYS" that responds to a subset of the
ANSI X3.64 control codes - enough to configure your display and keyboard.
Install the DOS console driver by adding the statement:
device = ANSI.SYS
to your "CONFIG.SYS" file. Make sure DOS can find the file ANSI.SYS
by copying it from the DOS system disk to your "working" system disk.
If you have a fixed disk, copy ANSI.SYS to the root directory of C:\.
If you have no CONFIG.SYS file, you can create one by typing...
...at the DOS prompt> copy con config.sys <cr>
device = ANSI.SYS <cr>
buffers = 24 <cr>
<ctrl-Z><cr>
This file tells DOS to use the ANSI console driver - and tells DOS to
use 12Kb of RAM to buffer disk data. Change the number of BUFFERS to
fine tune disk I/O. The default disk buffer is about 2Kb.
DOS reads CONFIG.SYS when you fire up your PC or reboot: CTRL-ALT-DEL.
______ ESCAPE SEQUENCES ________________driver: DOS ANSI.SYS_____________
source: DOS Technical Reference
ESC [#A cursor up # lines
where # = number of lines to move
default # = 1
ignored at top of screen
ESC [#B cursor down # lines
where # = number of lines to move
default # = 1
ignored at bottom of screen
ESC [#C cursor right # columns
where # = number of columns to move
default # = 1
ignored at end of screen
ESC [#D cursor left # columns
where # = number of cols to move
default # = 1
ignored at beginning of screen
ESC [r;cH position cursor at row r column c
where r = 1 to 24 and c = 1 to 80
default r = 1 default c = 1
ESC [r;cf position cursor at row r column c
where r = 1 to 24 and c = 1 to 80
default r = 1 default c = 1
ESC [6n cursor position request - console
sends back cursor position report:
ESC [r;cR cursor position report...
where r = row and c = col
...in response to ESC [6n request.
ESC [s save current cursor position.
the cursor is not moved, but its
position is saved by DOS
ESC [u restore current cursor position.
the cursor is moved to the saved
row and column
__________________________________________________________________________
ESC [2J clear screen - sends cursor home.
ESC [K erase from cursor to end of line.
__________________________________________________________________________
ESC [#;...;#m set graphics rendition to #
where # include the following:
00 = all attributes OFF
01 = bold ON
04 = underscore (mono only)
05 = blink ON
07 = reverse ON
08 = concealed ON
30 = black foreground
31 = red foreground
32 = green foreground
33 = yellow foreground
34 = blue foreground
35 = magenta foreground
36 = cyan foreground
37 = white foreground
40 = black background
41 = red background
42 = green background
43 = yellow background
44 = blue background
45 = magenta background
46 = cyan background
47 = white background
EXAMPLE: ESC [01m ...sets BOLD ON
EXAMPLE: ESC [00;37;44m ...sets WHITE on BLUE
__________________________________________________________________________
ESC [=#h set screen mode to # where # =
or ESC [=h
or ESC [=0h 0 = 40x25 BLK & WHT
or ESC [?7h 1 = 40x25 COLOR
2 = 80x25 BLK & WHT
3 = 80x25 COLOR
4 = 320x200 COLOR
5 = 320x200 BLK & WHT
6 = 640x200 BLK & WHT
7 = wrap at end of line
ESC [=#l reset screen mode to # where # =
or ESC [=l
or ESC [=0l 0 = 40x25 BLK & WHT
or ESC [?7l 1 = 40x25 COLOR
2 = 80x25 BLK & WHT
3 = 80x25 COLOR
4 = 320x200 COLOR
5 = 320x200 BLK & WHT
6 = 640x200 BLK & WHT
7 = truncate at end of line
__________________________________________________________________________
ESC [#;#p redefine keyboard:
or ESC [#;"string"p
or ESC [#;"string";#;"string";#p The first # ASCII code
specifies which key is to
or any other combination of be redefined. Following
strings and decimal numbers # numbers or "strings"
redefine the key to ASCII
codes and/or strings.
where # is the decimal number of an ASCII character:
dec character dec key dec key dec key
0 ^@ NUL 32 <space> 64 @ 96 `
1 ^A SOH 33 ! 65 A 97 a
2 ^B STX 34 " 66 B 98 b
3 ^C ETX 35 # 67 C 99 c
4 ^D EOT 36 $ 68 D 100 d
5 ^E ENQ 37 % 69 E 101 e
6 ^F ACK 38 & 70 F 102 f
7 ^G BEL 39 ' 71 G 103 g
8 ^H BS 40 ( 72 H 104 h
9 ^I HT 41 ) 73 I 105 i
10 ^J LF 42 * 74 J 106 j
11 ^K VT 43 + 75 K 107 k
12 ^L FF 44 , 76 L 108 l
13 ^M CR 45 - 77 M 109 m
14 ^N SO 46 . 78 N 110 n
15 ^O SI 47 / 79 O 111 o
16 ^P DLE 48 0 80 P 112 p
17 ^Q DC1-XON 49 1 81 Q 113 q
18 ^R DC2 50 2 82 R 114 r
19 ^S DC3-XOFF 51 3 83 S 115 s
20 ^T DC4 52 4 84 T 116 t
21 ^U NAK 53 5 85 U 117 u
22 ^V SYN 54 6 86 V 118 v
23 ^W ETB 55 7 87 W 119 w
24 ^X CAN 56 8 88 X 120 x
25 ^Y EM 57 9 89 Y 121 y
26 ^Z SUB 58 : 90 Z 122 z
27 ^[ ESC 59 ; 91 [ 123 {
28 ^\ FS 60 < 92 \ 124 |
29 ^] GS 61 = 93 ] 125 }
30 ^^ RS 62 > 94 ^ 126 ~
31 ^_ US 63 ? 95 _ 127 DEL
where # is the decimal number of a "special" character:
dec char dec char dec char dec char
128 Ç 160 á 192 └ 224 α
129 ü 161 í 193 ┴ 225 ß
130 é 162 ó 194 ┬ 226 Γ
131 â 163 ú 195 ├ 227 π
132 ä 164 ñ 196 ─ 228 Σ
133 à 165 Ñ 197 ┼ 229 σ
134 å 166 ª 198 ╞ 230 µ
135 ç 167 º 199 ╟ 231 τ
136 ê 168 ¿ 200 ╚ 232 Φ
137 ë 169 ⌐ 201 ╔ 233 Θ
138 è 170 ¬ 202 ╩ 234 Ω
139 ï 171 ½ 203 ╦ 235 δ
140 î 172 ¼ 204 ╠ 236 ∞
141 ì 173 ¡ 205 ═ 237 φ
142 Ä 174 « 206 ╬ 238 ε
143 Å 175 » 207 ╧ 239 ∩
144 É 176 ░ 208 ╨ 240 ≡
145 æ 177 ▒ 209 ╤ 241 ±
146 Æ 178 ▓ 210 ╥ 242 ≥
147 ô 179 │ 211 ╙ 243 ≤
148 ö 180 ┤ 212 ╘ 244 ⌠
149 ò 181 ╡ 213 ╒ 245 ⌡
150 û 182 ╢ 214 ╓ 246 ÷
151 ù 183 ╖ 215 ╫ 247 ≈
152 ÿ 184 ╕ 216 ╪ 248 °
153 Ö 185 ╣ 217 ┘ 249 ∙
154 Ü 186 ║ 218 ┌ 250 ·
155 ¢ 187 ╗ 219 █ 251 √
156 £ 188 ╝ 220 ▄ 252 ⁿ
157 ¥ 189 ╜ 221 ▌ 253 ²
158 ₧ 190 ╛ 222 ▐ 254 ■
159 ƒ 191 ┐ 223 ▀ 255 0FFhex
IBM PC console keys are specified by an "extended ASCII" code:
for: ESC [#;#;...p
if first '#' = 0 <NUL>;
then second '#' = the extended ASCII coded key:
59 to 68 = Function Keys F1 to F10
94 to 103 = CTRL- F1 to F10
84 to 93 = SHIFT- F1 to F10
104 to 113 = ALT- F1 to F10
15 = SHIFT-Tab
120 to 131 = ALT- 1 2 3 4 5 6 7 8 9 0 - =
16 to 25 = ALT- Q W E R T Y U I O P
30 to 38 = ALT- A S D F G H J K L
43 to 50 = ALT- \ Z X C V B N M
82 = Insert
83 = Delete
71 = Home
79 = End
75 = Cursor Left
77 = Cursor Right
72 = Cursor Up
80 = Cursor Down
73 = Page Up
81 = Page Down
3 = NUL ( since 0 is index to this table )
EXAMPLE: ESC [36;156p ...changes $ to £ character
EXAMPLE: ESC [36;36p ...and then back to $
EXAMPLE: ESC [0;59;"DIR";13p ...sets F1 to DIR<cr>
EXAMPLE: ESC [0;59;0;59p ...and then back to F1
__________________________________________________________________________
You create console utilities by putting ESC commands in batch files.
This example modifies display attributes whenever you enter BLUE...
...at the DOS prompt> copy con blue.bat <cr>
esc [00;34;40m <cr>
<ctrl-Z><cr>
Use ESC commands to enhance existing batch files. This D.BAT displays
a direcory listing using BLUE.BAT:
___________________
echo off
blue ...run BLUE.BAT
esc [2J ...clear screen
dir ...display files
esc [00;32;40m ...make prompt GRN
__________________________________________________________________________
The DOS PROMPT command can send ANSI escape sequences to your console.
Try the following PROMPT:
( mono ) A> PROMPT $e[01m$p$g $e[00m$e[K
( color ) A> PROMPT $e[01;36;40m$p$g $e[00;32m$e[K
This sequence upgrades your 'A>' DOS prompt to a bold cyan that shows
the current directory; sets screen attributes to GRN on BLK; clearing
the prompt line for your command. Changes remain in effect until you
issue another PROMPT command. DOS PROMPT syntax includes:
$e = escape character
$n = current drive
$g = the > character
$p = current directory
$d = current date
$t = current time
$v = DOS version
$l = the < character
$q = the = character
$b = the | character
$$ = the $ character
$h = backspace
$_ = <cr><lf>
$. = NUL character
$n$g = default PROMPT
__________________________________________________________________________
Put the console configuration that suits you into the file EXEC.BAT.
This example defines a key to run EXEC on your command:
____________________
echo off
esc [=3h ...80x25 color mode
esc [=7h ...autowrap ON
esc [00;32;40m ...green on black
esc [2J ...clear screen
esc [0;59;"CLS";13;"DIR";13p F1 = display files
esc [0;60;"CHKDSK";13p F2 = status report
esc [0;61;"A:";13p F3 = select A:
esc [0;62;"EDIT";13p F4 = run EDIT.BAT
esc [0;63;"B:";13p F5 = select B:
esc [0;64;"CALC";13p F6 = run CALC.BAT
esc [0;65;"C:";13p F7 = select C:
esc [0;66;"COMM";13p F8 = run COMM.BAT
esc [0;67;"D:";13p F9 = select D:
esc [0;68;"EXEC";13p F10 = run EXEC.BAT
prompt $e[01;36;40m$p$g $e[00;32m$e[K ...custom prompt
Edit EXEC.BAT to fine tune your custom console. Make EXEC the default
console configuration by running it from AUTOEXEC.BAT.
EXEC should provide a friendly environment for you to issue commands
to the DOS prompt. Application programs present different prompts
to the console operator.
Copy EXEC to create new batch files such as EDIT, CALC, and COMM.BAT.
These files should: configure the console for a specific application;
run the program; and end with EXEC to reconfigure the console before
returning to DOS.
__Technical Notes_________________________________________________________
Because ESC.COM sends escape sequences to the "standard output" device,
you can redirect control codes to other DOS devices, such as a printer.
Use DOS "console redirection" to send an escape sequence to LPT1:
ESC xxxxxx >LPT1:
This is useful for selecting print modes from your console; configuring
your printer on power up; and custom printing of text files. Codes are
documented in your printer manual.
You can redirect escape codes to a file. Creative users will find...
ESC xxxxxx >config.con
...makes a file named CONFIG.CON containing an ANSI control code. Edit
this file to change the escape sequence. Send CONFIG.CON to CON:
TYPE config.con
or COPY config.con CON:
...and your ANSI console will respond to the control code in the file.
Copy CONFIG.CON to CONFIG.PRN and edit this file. Send CONFIG.PRN to
your printer with:
COPY config.prn LPT1:
You could create a library of escape sequences, each a single file.
Use your editor to insert control codes from the library into text.
Such files display text in color at any location on the screen, or
print text in different styles on dot-matrix printers.
To append additional escape sequences to an existing file, use:
ESC xxxxxx >>config.con
It is more efficient to copy an ANSI configuration file containing
a string of escape sequences directly to CON: -- than it is to run
ESC.COM many times from a batch file.
Redirect configuration batch files to "compile" them into simpler
files containing control code strings. For example...
EXEC >exec.con
....redirects everything EXEC.BAT displays > to the file EXEC.CON.
Edit this file to delete characters that are not escape sequences.
What EXEC.BAT used to do is now accomplished simply:
TYPE exec.con
__________________________________________________________________________
ANSI.SYS is a subset of the full ANSI X3.64 standard - some console
drivers have more features. The most elegant ANSI is called FANSI.
FANSI provides back-scrolling and a type-ahead buffer, and features
high speed screen and keyboard drivers.
Hersey Micro Consulting, Inc.
P.O. Box 8276
Ann Arbor, MI 48107
voice: (313) 994-3259 0900 to 1700 EST
modem: (313) 994-3946 2300 to 0800 EST
__________________________________________________________________________
This disk copy provided as a service of
The Public (Software) Library
For a copy of the latest monthly software library newsletter
and a list of the 600+ disks in the library, call or write
The Public (Software) Library
P.O.Box 35705
Houston, TX 77235-5705
(713) 721-6104
Newsletter subscriptions are available for $12 a year.